<?php
include_once 'protocol_includes.php';

class Logout extends subapplication
{
    private $cmd;
    public static $PROTOCOL = "Logout";

    public static function create(command $cmd)
    {
        if (!self::IsThisClass($cmd)) return null;
        $N = new Logout($cmd);
        return $N;
    }

    public function __construct(command $cmd)
    {
        $this->cmd  = $cmd;
        $this->LoginKey($cmd->GetData('LOGINKEY'));
    }

    public function  requiresAuthentication() {
        return false;
    }

    public function execute()
    {
        ns_dao_user::KillLoginKey($this->LoginKey());
        $returnString = "NS_PROTOCOL=AuthFailed";
        $this->UpdateResult($returnString);
    }

    // =========== PROPERTIES ==========

    private $property = array();
    private function GetSetData($property_name,$value = null)
    {
        if (is_null($value) && isset($this->property[$property_name])) return $this->property[$property_name];
        $this->property[$property_name] = $value;
    }

    public function LoginKey($value = null)
    {
        return $this->GetSetData("LOGINKEY",$value);
    }

    public function result()
    {
        $this->cmd->GetResult();
    }

    public function UpdateResult($str)
    {
        $this->cmd->SetResult($str);
    }

    /*
     * check to see if command is a UPLOAD
     */
    public static function IsThisClass(command $cmd)
    {
        if (!$cmd->HasDataKey('LOGINKEY')) return false;
        return true;
    }

    
}

?>
